<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>third</title>
<link href="css/third.css" type=text/css rel=stylesheet>
<link href="css/private.css" type=text/css rel=stylesheet>
</head>
<body>
		<table class="table table-bordered table-striped">
				<thead>
					<tr>
						<th style="width:50px;">编号</th>
						<th style="width:200px;">账号</th>
						<th style="width:200px;">密码</th>
						<th style="width:200px;">身份信息</th>
						<th style="width:200px;">操作</th>
					</tr>
				</thead>
			<tbody>
				<c:forEach items="${sys_user}" var="row">
					<tr>
						<td style="height:30px">${row.id}</td>
						<td style="height:30px">${row.username}</td>
						<td style="height:30px">${row.password}</td>
						<td style="height:30px">${row.identity}</td>
						<td>
							<a style="width:50px;height: 30px;" class="add" href="#" onclick="changedis()">&nbsp;新建&nbsp;</a>
							<a style="width:50px;height: 30px;" class="del" href="#" onclick="delUser(${row.id})">&nbsp;删除&nbsp;</a>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div id="cov">
			<div id="hid">
				
				<div>
				<h3>添加工作人员账号</h3>
				</div>
				<form action="addUser.action" method="post" id="edit_form"> 
					 <label>账号</label><input type="text" id="username" name="username"/><br>
					 <label>密码</label><input type="text" id="password" name="password"/><br>
					 <br>
					 <input type="submit" class="btn" onclick="add()" value="添加">
					 <input type="reset" class="btn" onclick="changehid()" value="关闭">
		        </form>
			</div>
		</div>
</body>
<script>
function changedis(){
	document.getElementById("hid").style.display="block";
	document.getElementById("cov").style.display="block";	
}
function changehid(){
    document.getElementById("hid").style.display="none";
    document.getElementById("cov").style.display="none";
}
function add(){
	alert(${addmsg});
}
//删除工作人员账号
function delUser(id) {
    if(confirm('确定要删除该工作账号吗?')) {
		$.post("<%=basePath%>third/delete1.action",{"id":id},
			function(data){
	            if(data =="OK"){
	                alert("账号删除成功！"); 
	                window.location.reload();
	            }else{
	                alert("账号删除失败！");
	                window.location.reload();
	            }
        });
    }  
}
</script>
</html>